package testing.manager;

import java.awt.Color;
import java.awt.Container;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.util.Properties;

import testing.module.BoxAndCircle;
import utilities.manager.Runner;
import utilities.module.Module;

public class BoxAndCircleRunner extends Runner
{
	/**
	 * 
	 */
	private static final long serialVersionUID = -1712076549823158366L;
	
	private Module whatCouldThisBe = null;

	public BoxAndCircleRunner(int width, int height, Color backgroundColor, Container p) 
	{
		super(width, height, backgroundColor);
		whatCouldThisBe = new BoxAndCircle(p);
	}

	public void gameUpdate(Properties runnerVars) 
	{
		// What's going on???
		if(whatCouldThisBe != null) whatCouldThisBe.update(null);
	}

	public void drawScreen(Graphics g) 
	{
		// Type cast
		Graphics2D g2 = (Graphics2D) g;
		
		// Get original settings...
		Color c = g2.getColor();
		
		// Draw background
		drawBackgroundColor(g2);
		
		// Draw spazzy rectangle
		drawContent(g2);
		
		// Return original settings...
		g2.setColor(c);
	}

	/**
	 * 
	 * @param g2
	 */
	public void drawContent(Graphics2D g2) 
	{
		if(whatCouldThisBe != null)
		{
			whatCouldThisBe.drawMe(g2);
		}
	}

	/**
	 * 
	 * @param g2
	 */
	public void drawBackgroundColor(Graphics2D g2)
	{
		g2.setColor(this.getBackground());
		g2.fillRect(0, 0, this.getWidth(), this.getHeight());
	}
	
	public Module getModule()
	{
		return whatCouldThisBe;
	}
}
